﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AskForMore.aspx.cs" Inherits="BEGDC.CC.Web.Workflow.Dialog.AskForMore" %>


<%@ Register TagPrefix="cc1" Namespace="BEGDC.CC.Web.Control" Assembly="ASBCC.Web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>
        <%=Resources.Workflow.AskForMore%></title>
    <link href="../../css/global.css" type="text/css" rel="stylesheet" />
    <link href="../../css/style.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript" language="javascript">
        var sourceActionButton;

        function validateExecute() {
            var actionType = sourceActionButton.actionType;
            if (actionType == "Reject" || actionType == "AskForMore") {
                var comment = document.getElementById("txtComments").value;
                if (comment == null || comment == "") {
                    alert(document.getElementById("hidCommentRequired").value);
                    return false;
                }
                //添加新的抄送人验证
//                var tmp = document.getElementById("SearchStaff_Employee_Flow_ID").value;
//                document.getElementById("hidForwardTargetUserID").value = tmp;
//                if (tmp == "" || tmp == "0") {
//                    alert(document.getElementById("hidForwardTargetRequired").value);
//                    return false;
//                }
               
                return true;
            }
            return true;
        }

        function execute() {
            if (!validateExecute()) return;
            if (opener && opener.__wf_doActionPostBack) {
                var comment = document.getElementById("txtComments").value;
                var auditDestination = getAuditDestination();
                if (auditDestination == null) {
                    alert(document.getElementById("hidAskForMoreTargetRequired").value);
                    return;
                }
                opener.__wf_doActionPostBack(sourceActionButton, auditDestination, comment);
                window.close();
            }
        }

        window.onload = function() {
            sourceActionButton = opener.__wf_sourceActionButton;
        }

        function getAuditDestination() {
            var Obj = document.getElementById("lstSelectUsers");
            var ischecked = false;
            var askforuser = "";
            var ObjList = Obj.getElementsByTagName("INPUT");
            for (var i = 0; i < ObjList.length; i++) {
                if (ObjList[i].checked) {
                    askforuser = ObjList[i].value;
                    ischecked = true;
                }
            }
            if (!ischecked) {
                return null;
            }

            var SEPARATOR_USER = ';';
            var SEPARATOR_ACTIVITY_DESTINATION = '|';
            var SEPARATOR_AUDIT_DESTINATION = '$';
            var ProcInstId = document.getElementById("hidProcInstId").value;

            var activityName = askforuser.substring(askforuser.indexOf('-') + 1);
            var user = askforuser.split('-')[0];

            var tmp = document.getElementById("SearchStaff_Employee_Flow_ID").value;
            document.getElementById("hidForwardTargetUserID").value = tmp;
            
            var ccuser = document.getElementById("hidForwardTargetUserID").value;
             
            if (ccuser != "") {
                return "askformore:" + activityName + SEPARATOR_ACTIVITY_DESTINATION + ProcInstId + SEPARATOR_ACTIVITY_DESTINATION + user + SEPARATOR_ACTIVITY_DESTINATION + ccuser;
            }
            else {
                return "askformore:" + activityName + SEPARATOR_ACTIVITY_DESTINATION + ProcInstId + SEPARATOR_ACTIVITY_DESTINATION + user;
            }
        }
    </script>

</head>
<body style="background: none;">
    <h3 class="ev-header-section">
        &nbsp;ASK FOR MORE</h3>
    <form id="form1" runat="server">
    <table width="100%">
        <tr class="ev-row2">
            <td class="title" width="18%">
                <span class="Star">*</span>Select Users ：<br />选择用户&nbsp;&nbsp;
            </td>
            <td class="val">
                <asp:RadioButtonList ID="lstSelectUsers" runat="server" RepeatDirection="Vertical">
                </asp:RadioButtonList>
            </td>
        </tr>
         <tr class="ev-row2">
            <td class="title" width="18%">
                Select User ：<br />
                选择抄送人&nbsp;&nbsp;
            </td>
            <td class="val">
                <asp:HiddenField ID="hidForwardTargetUserID" runat="server"></asp:HiddenField>
                <cc1:UserSearchControl ID="SearchStaff" runat="server" Width="90%"></cc1:UserSearchControl>
            </td>
        </tr>
        
        
        <tr class="ev-row2">
            <td class="title">
                <span class="Star">*</span>Your Comments ：<br />您的审批意见&nbsp;&nbsp;
            </td>
            <td class="val">
                <asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine" Rows="6" Width="98%"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td colspan="2" class="padding5 ac">
                <br />
                <asp:Button runat="server" ID="btnAskForMore" Text="<%$ Resources:Workflow, AskForMore%>" CssClass="btn" OnClientClick="execute(); return false;"
                    UseSubmitBehavior="false" />&nbsp;
                <asp:Button runat="server" ID="btnCancel" Text="<%$ Resources:Workflow, Cancel%>" CssClass="btn" OnClientClick="window.opener=null;window.close(); return false;"
                    UseSubmitBehavior="false" />
            </td>
        </tr>
    </table>
    <asp:HiddenField ID="hidAskForMoreTargetRequired" runat="server" />
    <asp:HiddenField ID="hidForwardTargetRequired" runat="server" />
    <asp:HiddenField ID="hidCommentRequired" runat="server" />
    <asp:HiddenField ID="hidProcInstId" runat="server" />
    </form>
</body>
</html>